home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / iflib / bwrite.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-04  |  945 b   |  62 lines

  1. #include <stdio.h>
  2. #include "bwrite.h"
  3. #include "config.h"
  4.  
  5. /* write short (16bit) integer in "standart" byte order */
  6. int iwrite(i,fp)
  7. int i;
  8. FILE *fp;
  9. {
  10.     putc(i & 0xff,fp);
  11.     putc((i >> 8) & 0xff,fp);
  12.     return 0;
  13. }
  14.  
  15. /* write long (32bit) integer in "standart" byte order */
  16. int lwrite(i,fp)
  17. long i;
  18. FILE *fp;
  19. {
  20.     int c;
  21.  
  22.     for (c=0;c<32;c+=8) putc((i >> c) & 0xff,fp);
  23.     return 0;
  24. }
  25.  
  26. int awrite(s,fp)
  27. char *s;
  28. FILE *fp;
  29. {
  30.     while (*s) putc(outtab[*(s++) & 0xff], fp);
  31.     putc(0,fp);
  32.     return 0;
  33. }
  34.  
  35. /* write an arbitrary line to message body: change \n to \r\n */
  36. int cwrite(s,fp)
  37. char *s;
  38. FILE *fp;
  39. {
  40.     while (*s) 
  41.     {
  42.         if (*s == '\n') putc('\r',fp);
  43.         putc(outtab[*(s++) & 0xff],fp);
  44.     }
  45.     return 0;
  46. }
  47.  
  48. /* write (multiline) header to kluge: change \n to ' ' and end line with \r */
  49. int kwrite(s,fp)
  50. char *s;
  51. FILE *fp;
  52. {
  53.     while (*s) 
  54.     {
  55.         if (*s != '\n') putc(outtab[*s & 0xff],fp);
  56.         else if (*(s+1)) putc(' ',fp);
  57.         s++;
  58.     }
  59.     putc('\r',fp);
  60.     return 0;
  61. }
  62.